using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Maxleaf.EDI.Domain.EDI;

namespace Maxleaf.EDI.DataAccess.EDI.Mapping
{
    public class User_DBMap : EntityTypeConfiguration<User_DB>
    {
        public User_DBMap()
        {
            // Primary Key
            this.HasKey(t => new { t.UserName });

            // Properties
            this.Property(t => t.UserID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.DBID)
                .HasMaxLength(500);

            this.Property(t => t.UserName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Password)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.FDeleted)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("User_DB");
            this.Property(t => t.UserID).HasColumnName("UserID");
            this.Property(t => t.DBID).HasColumnName("DBID");
            this.Property(t => t.UserName).HasColumnName("UserName");
            this.Property(t => t.Password).HasColumnName("Password");
            this.Property(t => t.FDeleted).HasColumnName("FDeleted");
        }
    }
}
